import service from '@/utils/request'
import {ApiResponse,ListApiResponse} from '@/store/dataType.ts'

// BPM 流程监听器 VO
export interface ProcessListenerVO {
  id: number // 编号
  name: string // 监听器名字
  type: string // 监听器类型
  enabled: boolean // 监听器状态
  event: string // 监听事件
  valueType: string // 监听器值类型
  value: string // 监听器值
}

// BPM 流程监听器 API
export const API_PROCESS_LISTENER = {
  // 查询流程监听器分页
  getProcessListenerPage: async (params: any):Promise<ListApiResponse> => {
    return await service.get( `/workflow/process-listener/list`,{ params })
  },

  // 查询流程监听器详情
  getProcessListener: async (id: number):Promise<ApiResponse> => {
    return await service.get(`/workflow/process-listener/` + id )
  },

  // 新增流程监听器
  createProcessListener: async (data: ProcessListenerVO):Promise<ApiResponse> => {
    return await service.post(`/bpm/process-listener/create`, data )
  },

  // 修改流程监听器
  updateProcessListener: async (data: ProcessListenerVO):Promise<ApiResponse> => {
    return await service.put(`/bpm/process-listener/update`, data )
  },

  // 删除流程监听器
  deleteProcessListener: async (id: number):Promise<ApiResponse> => {
    return await service.delete(`/bpm/process-listener/delete/` + id )
  }
}